<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>08-event事件对象</title>
    <script>
        window.onload=function () {
            // 获取父子 div 对象
            let parentEle = document.getElementById("parent");
            let childEle = document.getElementById("child");
            // 给父子 div 绑定事件
            parentEle.onclick=function () {
                alert("父div被单击");
            }
            childEle.onclick=function () {
                alert("子div被单击");
                // 阻止事件冒泡
                event.stopPropagation();
            }
            let aArr = document.getElementsByTagName("a")[0];
            aArr.onclick=function () {
                alert("a标签被点击");
                event.preventDefault();
                let target = event.target;
                console.log(target);

            }
        }
    </script>
</head>
<body>
<div id="parent">
    我是parent盒子
    <div id="child">
        我是child盒子
    </div>
</div>
<a href="http://www.baidu.com" id="a1">点我跳转百度</a>
</body>
</html>